cmake_minimum_required(VERSION 2.8)
project(hello)

#set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_BUILD_TYPE "Debug")

if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEBUG -g -ggdb -O0 -fPIC ")
else()
        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -fPIC ")
endif()

set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEXPORT -std=c++0x -pthread")

EXECUTE_PROCESS(COMMAND arch
        OUTPUT_VARIABLE PLATFORM
        OUTPUT_STRIP_TRAILING_WHITESPACE
        )        
MESSAGE(STATUS "PLATFORM:${PLATFORM}")

EXECUTE_PROCESS(COMMAND git branch
        TIMEOUT 5
        OUTPUT_VARIABLE GIT_BRANCH
        OUTPUT_STRIP_TRAILING_WHITESPACE
        )
MESSAGE(STATUS "BUILD FROM GIT BRANCH ${GIT_BRANCH}")

file(GLOB_RECURSE SOURCE_FILES
        ${PROJECT_SOURCE_DIR}/src/*.cpp
        ${PROJECT_SOURCE_DIR}/src/*.cc
)

include_directories(
        ${PROJECT_SOURCE_DIR}/include
)

link_directories(
        ${PROJECT_SOURCE_DIR}/lib
)

add_executable(${PROJECT_NAME} ${SOURCE_FILES})

target_link_libraries(
        ${PROJECT_NAME}
        dl rt
        pthread
        spdlog
)
